<!-- 工单类型 -->
<template>
    <div class="ticketType">
        <div class="common_step">
            <div class="common_title">
                <div class="breadcrumb">
                    <div class="breadcrumb__item breadcrumb__item--center" @click="goBack()">检修报修</div>
                    <div class="breadcrumb__item">/</div>
                    <div class="breadcrumb__item breadcrumb__item--center">工单类型</div>
                </div>
                <div class="breadcrumbBtn">
                    <div class="btn_ative" @click="goBack()">
                        <img class="operation_btn" src="@/assets/images/images_new/back_icon.png" alt="">
                        <span>返回</span>
                    </div>
                </div>
            </div>
            <div class="serchBar">
                <div class="left">
                    <el-form class="form" :model="searchData" label-position="left">
                        <el-form-item label="类型名称">
                            <el-input v-model="searchData.params.title" placeholder="类型名称"></el-input>
                        </el-form-item>
                    </el-form>
                </div>
                <div class="right">
                    <div class="btn_bg" title="搜索" @click="searchList">
                        <img class="btn_icon search_icon" src="@/assets/images/images_new/search_icon.png" alt="">
                    </div>
                    <div class="btn_bg btn_bg2" title="清空" @click="empty">
                        <img class="btn_icon reset_icon" src="@/assets/images/images_new/reset_icon.png" alt="">
                    </div>

                </div>
            </div>
        </div>
        <div class="rule_content">
            <div class="btn">
                <div class="btn_item" @click="pushAdd">
                    <img class="btn_icon" src="@/assets/images/images_new/add_icon.png" alt="">
                    <span>新增</span>
                </div>
                <div class="btn_item" @click="delItem">
                    <img class="btn_icon" src="@/assets/images/images_new/del_icon.png" alt="">
                    <span>删除</span>
                </div>
            </div>
            <div class="table">
                <div class="lef">
                    <menuTree></menuTree>
                </div>
                <div class="right">
                    <div class="tableBg">
                        <el-table ref="tableRef" :data="tableData.list" style="width: 100%;" stripe
                            @selection-change="handleSelectionChange" empty-text="暂无数据" :max-height="table_height"
                            :scrollbar-always-on="true">
                            <el-table-column type="index" label="序号" width="200" />
                            <el-table-column property="name" label="类型名称"
                                :min-width="flexWidth('name', tableData.list, '类型名称')" />
                            <el-table-column label="操作" width="75px" class-name="fixed_column" fixed="right">
                                <template #default="scope: any">
                                    <div class="btn_ative" title="编辑" @click="viewDetails(scope.row)">
                                        <img class="operation_btn" src="@/assets/images/images_new/edit_icon.png"
                                            alt="">
                                    </div>
                                </template>
                            </el-table-column>
                        </el-table>
                    </div>

                </div>

            </div>
        </div>
        <!-- 分页组件 -->
        <div class="common_pagination">
            <CommonPagination2 :pageNum="searchData.pageNum" :pageSize="searchData.pageSize" :pageTotal="total"
                @pageFunc="pageFunc" @sizeChange="sizeChange"></CommonPagination2>
        </div>
        <addDialog :dialogVisible="addVisible" @closeDialog="closeAddDialog"></addDialog>
    </div>
</template>

<script setup lang="ts">
import router from '@/routes';
import { flexWidth } from '@/utils/utils'
import menuTree from './components/ticketType/menuTree.vue';
import addDialog from './components/ticketType/addDialog.vue';

const goBack = () => {
    router.go(-1);
}

const tableData = reactive({
    list: []
})

let searchData = reactive({
    pageNum: 1, //当前页
    pageSize: 10, //每页条目数
    params: {
        title: "", // 报警标题
        createTimeEnd: "", //结束时间
        createTimeStart: "",//开始时间
        msgType: null as any,//消息类型：1-通知公告，2-设备报警消息，3-网关报警消息
    }
})
let total = ref(0);
//搜索
const searchList = () => {

}

//清空
const empty = () => {

}

//删除
const delItem = () => {

}

//选中的行
const multipleSelection = reactive({
    list: [] as Array<string>
})

//多选项改变时
const handleSelectionChange = (val: any) => {
    let list = [] as Array<string>;
    if (val) {
        val.forEach((item: any) => {
            list.push(item.id);
        })
    }
    multipleSelection.list = list;
}

let table_height = ref(300);

//查看
const viewDetails = (row: any) => {

}


//页数改变事件(上一页,下一页,跳转到某一页)
const pageFunc = (pageNum: number) => {
    searchData.pageNum = pageNum;

}

//每页条数改变
const sizeChange = (pageSize: number) => {
    searchData.pageSize = pageSize;

}

let addVisible = ref(false);//是否打开新增弹窗
//新增
const pushAdd = ()=>{
    addVisible.value = true;
}

const closeAddDialog = ()=>{
    addVisible.value = false;
}
</script>

<style lang="scss" scoped>
.ticketType {
    background-color: #e5e5e5;
    height: 100%;
    width: 100%;
    padding: 0 15px;
    display: flex;
    flex-direction: column;
    position: relative;

    .common_step {
        height: 137px;
        background: rgb(255, 255, 255);
        // padding: 0 50px 15px 40px;
        border-radius: 0px 0px 8px 8px;

        .common_title {
            display: flex;
            justify-content: space-between;
            align-items: center;
            height: 85px;


            padding-left: 30px;

            .breadcrumb {
                width: 320px;
                height: 38px;
                display: flex;
                align-items: center;
                justify-content: space-between;
                padding: 0 10px;
                border: 1px solid rgba(0, 0, 0, 0.05);
                font-size: 16px;
                font-weight: 400;

                .breadcrumb__item {
                    display: flex;
                    align-items: center;

                    &:first-child {
                        cursor: pointer;
                    }
                }

                .breadcrumb__item--center {
                    flex: 1;
                    justify-content: center;
                }
            }

            .breadcrumbBtn {
                margin-right: 42.5px;
                display: flex;

                .btn_ative {
                    width: auto;
                    height: 35px;
                    line-height: 35px;
                    cursor: pointer;
                    display: inline-block;
                    margin-right: 18px;
                    display: flex;
                    align-items: center;
                    color: #353535;
                    font-size: 14px;
                    padding: 0 8px;

                    &:last-child {
                        margin-right: 0;
                    }

                    &:hover {
                        background: rgba(0, 0, 0, 0.1);
                        border-radius: 2px;
                    }

                    .operation_btn {
                        height: 20px;
                        margin-right: 7px;
                    }
                }

            }
        }

        .serchBar {
            // margin-top: 26px;
            display: flex;
            padding: 0 28px 20px 38px;

            .left {
                flex: 1;

                .el-form {
                    display: flex;
                    flex-wrap: wrap;

                    .el-form-item {
                        max-width: 100%;
                        padding-right: 50px;
                    }
                }

            }

            .right {
                width: 87px;
                height: 32px;
                flex-shrink: 0;
                display: flex;
                justify-content: flex-start;
                align-items: center;

                .btn_bg {

                    height: 35px;
                    width: 35px;
                    display: flex;
                    justify-content: center;
                    align-items: center;
                    cursor: pointer;

                    &:hover {
                        background: rgba(0, 0, 0, 0.1);
                        border-radius: 2px;
                    }

                    &.btn_bg2 {
                        margin-left: 17px;
                    }

                    .search_icon {
                        width: 21px;
                        cursor: pointer;
                    }

                    .reset_icon {
                        width: 20px;
                        cursor: pointer;
                    }
                }


            }
        }


    }

    .rule_content {
        flex: 1;

        .btn {
            display: flex;
            justify-content: flex-end;
            align-items: center;
            height: 40px;
            padding-right: 25px;
            color: rgb(112, 105, 95);
            font-size: 14px;

            .btn_item {
                display: flex;
                align-items: center;
                margin-left: 20px;
                cursor: pointer;
                height: 28px;
                line-height: 28px;
                padding: 0 10px 0 8px;

                &:hover {
                    background: rgba(0, 0, 0, 0.1);
                    border-radius: 2px;
                }

                .btn_icon {
                    width: 18px;
                    margin-right: 6px;
                }
            }
        }

        .table {
            height: calc(100% - 40px);
            overflow: hidden;
            display: flex;

            .right {
                flex: 1;
                padding-left: 19px;
                .tableBg {
                    border-radius: 8px;
                    background-color: #fff;
                    overflow: hidden;
                    height: 100%;
                }
            }
        }
    }

    .common_pagination {
        position: absolute;
        right: 50px;
        bottom: 40px;
    }
}
</style>
